package com.csgc.camera.widget.dialog

import android.content.Context
import android.widget.TextView
import androidx.core.content.ContextCompat

import com.csgc.camera.widget.dialog.base.CommonCenterDialog
import com.cysd.spsyxj.R


/**
 * 两个按钮提示dialog
 */
class CommonHandleTipsDialog(
    private val context: Context,
    private var title: String = "",
    private var leftTxt: String = "",
    private var rightTxt: String = "",
    private var content: String = ""
) {
    private lateinit var mDialog: CommonCenterDialog
    var listener: DialogActionListener? = null
    private var mContent:TextView?=null
    private var tipsType = ""

    init {
        initDialog()
    }

    private fun initDialog() {
        mDialog = CommonCenterDialog(context).apply {
            setCustomView(R.layout.dialog_common_handle_content)
            mContent = findViewById(R.id.tv_handle_content)
            mContent?.text = content
            setDialogTitle(title)
            setConfirm(rightTxt)
            setCancel(leftTxt)
            setCancelColor(ContextCompat.getColor(context, R.color.color_999999))
            setConfirmListener {
                mDialog.dismiss()
                listener?.sure(tipsType)
            }
            setCancelListener {
                mDialog.dismiss()
            }
            setCancelable(false)
        }
    }


    fun showDialog(title: String,content: String,type:String) {
        this.tipsType = type
        mDialog.setDialogTitle(title)
        mContent?.text = content
        mDialog.show()
    }

    fun showDialog(){
        mDialog.show()
    }

    fun dismissDialog() {
        mDialog.dismiss()
    }


    interface DialogActionListener {
        fun sure(type:String)
    }
}